<template>
    <!--//每个vue都要有一个div作为根标签-->
   <div class="login-wrap">
       <el-form class="login-container" :model="ruleForm"  :rules="rules" ref="ruleForm">
           <!--头部信息-->
           <h3 class="title">用户登录 </h3>
           <!--输入框-->
           <el-form-item prop="uid">
               <el-input v-model="ruleForm.uid" type="text" placeholder="账号"></el-input>
           </el-form-item>
           <el-form-item prop="password">
               <el-input v-model="ruleForm.password" type="password" placeholder="密码"></el-input>
           </el-form-item>
           <el-row>
               <!--验证码输入框-->
               <el-col :span="12">
                   <el-form-item prop="captcha">
                       <el-input  v-model="ruleForm.captcha" type="text" aria-placeholder="验证码"
                       @keyup.enter.n.native="submitForm('ruleForm')"
                       ></el-input>
                   </el-form-item>
               </el-col>
               <!--验证码图片-->
               <el-col :span="12" >
                   <img :src="codeImg" @click="getCode()"/>
               </el-col>
           </el-row>
           <el-form-item>
               <el-button type="primary" style="width: 100%" :loading="logining" @click="submitForm('ruleForm')">
                    登录
               </el-button>
           </el-form-item>

       </el-form>
   </div>
</template>

<script>
    export default {
        name: "Login",
        data(){
          return {
            //表单提交
            ruleForm:{
              uid:'',
              password:'',
              captcha:'',
              captchald:'',
            },
            //保存验证码图片
            codeImg:'',
            //限制规则
            rules:{
              uid:[{required:true,message:'请输入账号',trigger:'blur'}],
              password:[{required:true,message:'请输入密码',trigger:'blur'}],
              captcha: [{required:true,message:'请输入验证码',trigger:'blur'}]
            },
            //防止重复提交
            logining:false
          }
        },
      methods:{
          //提交表单
        submitForm(formName){

        },
        //获取验证码
        getCode(){

        }
      }
    }
</script>

<style scoped>
    .login-wrap {
        box-sizing: border-box;
        width: 100%;
        height: 100%;
        padding-top: 10%;
        background-image: url();
        background-repeat: no-repeat;
        background-position: center right;
        background-size: 100%;
    }

    .login-container {
        border-radius: 10px;
        margin: 0px auto;
        width: 350px;
        padding: 30px 35px 15px 35px;
        background: #fff;
        border: 1px solid #eaeaea;
        text-align: left;
        box-shadow: 0 0 20px 2px rgba(0, 0, 0, 0.1);
    }

    .title {
        margin: 0px auto 40px auto;
        text-align: center;
        color: #505458;
    }
</style>